<?php
/**
 * Created by JetBrains PhpStorm.
 * User: ishowshao
 * Date: 11-10-26
 */
include_once 'paperblog.php';
checkLogin();
$posts = getPosts();
$posts = array_reverse($posts);
$categorys = getCategorys();
$tags = getTags();
$settings = getSettings();
?><!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <title>文章列表</title>
    <style>
        body {
            font-size: 12px;
        }
        table {
            border: 1px solid #999;
        }
        table td {
            border: 1px solid #999;
            padding: 2px;
        }
    </style>
</head>
<body>
<table>
    <tr>
        <td>URL</td>
        <td>标题</td>
        <td>作者</td>
        <td>分类</td>
        <td>时间</td>
        <td>评论</td>
        <td>标签</td>
        <td>操作</td>
    </tr>
    <?php
    foreach ($posts as $post) {
    ?>
    <tr>
        <td><?php echo $post['url'] ?></td>
        <td><?php echo sprintf('<a href="%s/post/%s.html" target="_blank" title="查看文章">%s</a>', $settings['base'], $post['url'], $post['title']) ?></td>
        <td><?php echo $settings['author'] ?></td>
        <td><?php echo getCategoryNameById($post['category']) ?></td>
        <td><?php echo date('Y-m-d H:i:s', $post['time']) ?></td>
        <td><?php echo count($post['comments']) ?></td>
        <td><?php echo implode(',', $post['tag']) ?></td>
        <td>
            <?php
            echo sprintf('<a href="edit.php?id=%s&action=edit">编辑</a>&nbsp;', $post['url']);
            echo sprintf('<a href="edit.php?id=%s&action=delete">删除</a>', $post['url']);
            ?>
        </td>
    </tr>
    <?php
    }
    ?>
</table>
<div style="padding: 5px;"><a href="index.php">返回管理首页</a></div>
</body>
</html>
